package com.lkm.app_ui.ui.sale.p;

import com.lkm.app_ui.AppConfig;
import com.lkm.app_ui.AppConst;
import com.lkm.app_ui.MyApplication;
import com.lkm.app_ui.RunTimeData;
import com.lkm.app_ui.help.PrinterHelp;
import com.lkm.frame.task2.Task;
import com.lkm.frame.task2.TaskAdapter;
import com.lkm.javatool.lang.RunnablePR;
import com.lkm.market2_0.m.steelyardserver.SteelyardServerModule;
import com.lkm.market2_0.task.DefaultTaskExecutor;

import java.util.HashMap;



public class PrintTask extends TaskAdapter<HashMap<String, String>, Void, Boolean> {

    public PrintTask() {
        super(new DefaultTaskExecutor(true), PrintTask.class.getName() + ".sendDate", MyApplication.getInstance().getTaskManager2());
    }

    @Override
    public void onPreExecute() {
        super.onPreExecute();







    }
    

    public static void print(String data, String QRData) {
        Task<HashMap<String, String>, Void, Boolean> task = new PrintTask();
        HashMap<String, String> map = new HashMap<>();
        map.put("data", data);
        map.put("qr", QRData);

        task.setParam(map);

        task.action();
        task.execTask();

    }
    @Override
    public void doExecuting(HashMap<String, String> param) {
        super.doExecuting(param);
        mTaskExecutor.executorDoAsyncExecuting(new RunnablePR<HashMap<String, String>, Void>() {
            @Override
            public Void run(HashMap<String, String> param) {

//                String data = jsonP.get("data").getAsString("");
//                String qr = jsonP.get("qr").getAsString("");
                String data = param.get("data");
                String qr = param.get("qr");

                String orderInfoStr = data;
  {
                    try {

                        PrinterHelp.print(orderInfoStr, qr);
                    } catch (Exception e) {
                    }
                }


                complete(true);
                return null;
            }
        }, param);
    }
}
